CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

#INCLUDE & SOURCE
AUX_SOURCE_DIRECTORY(${DIR_include} INC_ak-lib)	
AUX_SOURCE_DIRECTORY(${DIR_src} 	SRC_ak-lib)	
SET(SRC_ak-lib_SOCKWIN 				${DIR_src}/ak_sockw.c)
SET(SRC_ak-lib_SOCKGNU 				${DIR_src}/ak_sockl.c)

SET(SRC_ak-lib_GENX					${DIR_src}/ak_genx.c)
SET(SRC_ak-lib_CLI 					${DIR_src}/ak_cli.c)
SET(SRC_ak-lib_DEV 					${DIR_src}/ak_devl.c)
SET(SRC_ak-lib_APP					${DIR_src}/ak_appl.c)
SET(SRC_ak-lib_SYS					${DIR_src}/ak_sysl.c)
SET(SRC_ak-lib_SCTP 				${DIR_src}/ak_sctp.c)
SET(SRC_ak-lib_SQL 					${DIR_src}/ak_sqlite.c)
SET(SRC_ak-lib_XML 					${DIR_src}/ak_xml2.c)
SET(SRC_ak-lib_LOG 					${DIR_src}/ak_log.c)

#LIBRARY Dynamic
IF(UNIX)
#Re-Construct the Source List
LIST(REMOVE_ITEM SRC_ak-lib ${SRC_ak-lib_SOCKWIN}
							${SRC_ak-lib_SQL} 
							${SRC_ak-lib_CLI}
							${SRC_ak-lib_DEV}
							${SRC_ak-lib_GENX}
							)

ADD_LIBRARY(ak-lib 				SHARED 		${SRC_ak-lib})
SET_TARGET_PROPERTIES(ak-lib 	PROPERTIES 	VERSION 0.1 	SOVERSION 1)
SET_TARGET_PROPERTIES(ak-lib 	PROPERTIES 	CLEAN_DIRECT_OUTPUT 		1)

INSTALL(TARGETS ak-lib 
		RUNTIME DESTINATION ${inst_BINDIR}
		LIBRARY DESTINATION ${inst_LIBDIR}
		ARCHIVE DESTINATION ${inst_LIBDIR})
		
ELSEIF(WIN32)
#Re-Construct the Source List
LIST(REMOVE_ITEM SRC_ak-lib ${SRC_ak-lib_SOCKGNU} 
							${SRC_ak-lib_CLI}
							${SRC_ak-lib_DEV}
							${SRC_ak-lib_APP}
							${SRC_ak-lib_SYS}
							${SRC_ak-lib_SCTP}
							${SRC_ak-lib_SQL}
							${SRC_ak-lib_XML}
							${SRC_ak-lib_GENX}
							${SRC_ak-lib_LOG}
							)

ENDIF()

#LIBRARY Static
ADD_LIBRARY(ak-lib_s 			STATIC 		${SRC_ak-lib})
SET_TARGET_PROPERTIES(ak-lib_s 	PROPERTIES 	CLEAN_DIRECT_OUTPUT 	1)
SET_TARGET_PROPERTIES(ak-lib_s 	PROPERTIES 	OUTPUT_NAME 					"ak-lib")

# TARGET & INSTALL
INSTALL(TARGETS ak-lib_s
		RUNTIME DESTINATION ${inst_BINDIR}
		LIBRARY DESTINATION ${inst_LIBDIR}
		ARCHIVE DESTINATION ${inst_LIBDIR})

#INSTALL(FILES 	${INC_ak-lib}	DESTINATION 	${inst_INCDIR})



#Exec Binary


IF(UNIX)
ADD_EXECUTABLE(ak_cli 		${SRC_ak-lib_CLI})
ADD_DEPENDENCIES(ak_cli 		ak-lib)
TARGET_LINK_LIBRARIES(ak_cli 	ak-lib )

ADD_EXECUTABLE(ak_dev 		${SRC_ak-lib_DEV})
ADD_DEPENDENCIES(ak_dev 		ak-lib)
TARGET_LINK_LIBRARIES(ak_dev 	ak-lib )

ADD_EXECUTABLE(ak_genx 		${SRC_ak-lib_GENX})
ADD_DEPENDENCIES(ak_genx 		ak-lib)
TARGET_LINK_LIBRARIES(ak_genx 	ak-lib )

ELSEIF(WIN32)

ENDIF()

INSTALL(TARGETS ak_cli
		RUNTIME DESTINATION ${inst_BINDIR}
		LIBRARY DESTINATION ${inst_LIBDIR}
		ARCHIVE DESTINATION ${inst_LIBDIR})

INSTALL(TARGETS ak_dev
		RUNTIME DESTINATION ${inst_BINDIR}
		LIBRARY DESTINATION ${inst_LIBDIR}
		ARCHIVE DESTINATION ${inst_LIBDIR})
